removed excess files
[EroBeats.git] / Djinn and Tonic - Erobeats / RhythmIO.cpp
blob020366e3b28e9de71f5bd74bc4b2cd79f84a2dfc
1 #include "RhythmIO.h"
6 RhythmIO::~RhythmIO()
9 std::vector<std::vector<int>> RhythmIO::createBeatPatterns(std::string path) {
10 return convertBeatMap(readBeatMap(path));
13 std::vector<int> RhythmIO::readBeatMap(std::string path) {
14 std::ifstream file(path);
15 std::string line;
16 getline(file, line);
17 std::vector<int> data = splitInt(line, ' ');
18 return data;
21 // trim out the zeros and get the times of each
22 std::vector<std::vector<int>> RhythmIO::convertBeatMap(std::vector<int> data) {
23 int count = 0;
24 int temp = 0;
25 std::vector<std::vector<int>> keys;
26 for (int numbers : data) {
27 count++;
28 if (numbers == 0) {
29 continue;
31 else if (numbers != 0) {
32 keys.push_back(std::vector<int>({numbers, count }));
34 else{
35 std::cout << " ERROR\n";
37 temp++;
38 std::cout << keys.at(temp - 1).at(0) << "\t";
40 return keys;
43 void RhythmIO::bufferBeatData(vector<vector<int>> keys, long long musicStart, vector<vector<long long >>* hitData, vector<vector<long long >>* cueData) {
44 int keySize = keys.size();
45 for (int i = 0; i < 16; i++) {
46 if (keyPositions < keySize) {
47 if (keys.at(keyPositions).at(0) > 0 && keys.at(keyPositions).at(0) < 10) {
48 hitData->push_back(std::vector<long long>({ musicStart + (long long)keys.at(keyPositions).at(1), keys.at(keyPositions).at(0) }));
49 std::cout << "\nHit Data:\t" << musicStart + (long long)keys.at(keyPositions).at(1) ;
51 else if (keys.at(keyPositions).at(0) >= 10) {
52 cueData->push_back(std::vector<long long>({ musicStart + (long long)keys.at(keyPositions).at(1), keys.at(keyPositions).at(0) }));
53 std::cout << "\nHit Data:\t" << musicStart + (long long)keys.at(keyPositions).at(1);
55 keyPositions++;
57 else break;